// pages/recruit/index/index.js
//获取应用实例
const tcity = require("../../../utils/citys.js");
const time = require('../../../utils/util.js');
const app = getApp();
var other = {};

Page({

  /**
   * 页面的初始数据
   */
  data: {
    flag_resume_list: true,

    //submit 封装 Start
    area_name: '',
    plat_id: '',
    anchor_type: '',
    pay_low: '',
    pay_high: '',
    salary_type: '',
    keep_pay: '',
    job_method: '4',
    page: 1,
    role: '',
    offset: 0,
    recommend_new: 1,
    move_card: false,
    //submit 封装 End
    anchor_page: 1,
    resumes: [], //所有
    resumes_odd: [], //奇数
    resumes_even: [], //偶数
    // 卡片切换列表
    list_page: 1,
    card_page: 1,
    not_consider: 0,
    now_num: 0,
    orign_num: 0,
    is_last: false,

    //初始当前current
    current_NOW: 0,


    //省市区 Start
    provinces: [],
    province: "",
    citys: [],
    city: "",
    countys: [],
    county: '',
    value: [0, 0, 0],
    values: [0, 0, 0],
    //code
    provincesCode: [],
    citysCode: [],
    countysCode: [],
    provinceCode: '',
    cityCode: '',
    countyCode: '',
    //省市区 End

    //选项卡 Flag
    area_show: true,
    plat_show: true,
    type_show: true,
    salary_show: true,
    cycle_show: true,
    recommend_show: true,


    leixing_num: '',
    yaoqiu_num: '',

    //开关
    flag_on: false,
    idx: '',
    plat_idx: '',
    plat_checked: false,
    expectindex: '0',
    baseindex: '0',
    platfromIndex: "-1",
    recuittypeindex: "-1",
    timelistindex: "-1",
    jobindex: "-1",
    mask_show: false,
    kong_show: true,
    oneMore: '1',
    twoMore: '1',

    flag_id:true,

    //约聊
    session_time: 3,
    session_flag: true,


    base_low: '',
    base_high: '',
    expect_low: '',
    expect_high: '',

    special: 1,
    flag_moreTag: false,

    flag_update: false,
    flag_today: false,

    //平台、类型循环
    platfrom: [],
    recuitType: [],
    timeList: [{
        id: 1,
        name: '月结',
        isSelected: false,
      },
      {
        id: 2,
        name: '周结',
        isSelected: false,
      },
      {
        id: 3,
        name: '日结',
        isSelected: false,
      },
    ],
    jobList: [{
        id: 1,
        name: '线上',
        isSelected: false,
      },
      {
        id: 2,
        name: '线下',
        isSelected: false,
      },
    ],
    expectList: [{
        pay_low: "",
        pay_high: "",
        name: '不限',
        isSelected: true,
      },
      {
        pay_low: "3000",
        pay_high: "",
        name: '3K以下',
        isSelected: false,
      },
      {
        pay_low: "3000",
        pay_high: "5000",
        name: '3K-5K',
        isSelected: false,
      },
      {
        pay_low: "",
        pay_high: "5000",
        name: '5K以上',
        isSelected: false,
      },
    ],
    baseList: [{
        keep_pay: "",
        name: "不限",
        isSelected: true,
      },
      {
        keep_pay: "1",
        name: "有底薪",
        isSelected: true,
      },
      {
        keep_pay: "2",
        name: "无底薪",
        isSelected: true,
      },
    ],

    //招聘信息
    recruit_info: [],
    list: [],
    recruit_phone: '',

    //banner
    banner: [],
    navInfo: [],


    // 卡片 Start
    touch_startX: '',
    touch_EndX: '',
    nolike: 2, //                     记得修改
    clickLike: '',
    recruit_id: '',
    show_modalWrap: true,
    modalIndex: '',

    //模态显示
    //more_show
    more_show: true,
    flag_phone: true,
    shape_show: true,
    flag_out: true,


    flag: true,
    flag_time: true,
    flag_share: true,
    text_time: '',
    reg_true: false,
    flag_contact: true,
    flag_info: true,
    flag_weixin: false,
    flag_qq: false,
    flag_email: false,

    flag_float: true,
    flag_falls: false,
    mark_falls: true,


    // 找主播弹框开始

    flag_find_anchor_nojob: true,
    flag_find_anchor_call: true,
    flag_find_anchor_stay: true,
    flag_find_anchor_call_no: true,
    flag_find_anchor_stay_no: true,
    flag_find_anchor_jobing: true,
    flag_find_anchor_call_bodou: true,
    flag_find_anchor_call_bodou_no: true,


    //简历信息获取
    phone_value: '',
    is_resume: '',
    nickname: '',
    age: '',
    sex: '',

    flag_list: false,



    // 卡片 End
    // 动画 Start
    animation: null,
    // 动画 End


    //招聘 找主播页面数据
    is_leave: '',
    resume_id: '',
    telephone: '',

    is_issue: '',
    residue_num: '',
    re_number: '',
    focus: false,
    reg_telephone: '',
    after_telephone: '',

    mini_index: 0,
    flag_index: '',

    //item翻页
    item_current: 0,
    item_page: 1,
    data_type: '',
    iteminfo_list: [],
    item_all: false,
    item_flag: true,
    recruit_info_all: [],
    iteminfo_list_old: [],
  },
  //去选择身份
  click_identity() {
    wx.navigateTo({
      url: '../../selectIdentity/selectIdentity',
    })
  },
  go_resume(e) {
    // console.log(e)
    let resume_id = e.currentTarget.dataset.resume_id;
    wx.navigateTo({
      url: '../../recruit/singleRecruit/singleRecruit?resume_id=' + resume_id + "&flag=col",
      // url: '../../recruit/singleRecruit/singleRecruit?resume_id=' + resume_id+,
    })
  },
  // item翻页
  change_item(e) {
    console.log(e)
    let type = e.currentTarget.dataset.type;
    if (type != "all") {
      this.setData({
        item_all: false,
      })
    } else {
      this.setData({
        item_all: true,
      })
    }
  },
  //item下拉加载
  itemlower(e) {
    // console.log(e)
    let item_page = parseInt(this.data.item_page) + 1;
    this.setData({
      item_page: item_page
    })
    this.itemInfo(item_page, this.data.data_type)
  },
  // 各个翻页数据源
  itemInfo(page, data_type) {
    wx.showLoading({
      title: '小主稍后~',
      mask: true,
    })
    var that = this;
    wx.request({
      url: app.globalData.url + 'api/resume/all/list',
      data: {
        token: app.globalData.token,
        page: page,
        data_type: data_type,
      },
      method: 'POST',
      success: (e) => {
        // console.log(e);
        var self = this;
        var total_page = e.data.data.total_page,
          item_page = that.data.item_page,
          iteminfo_list_old = that.data.iteminfo_list;
        if ((item_page > total_page) && (item_page == total_page)) {
          console.log("最后一页")
        } else {
          if (that.data.item_flag == true) {
            let iteminfo_list = e.data.data.list;
            self.setData({
              iteminfo_list: iteminfo_list,
              item_flag: false
            })
          } else {
            var iteminfo_list_new = e.data.data.list,
              iteminfo_list_old = iteminfo_list_old;
            iteminfo_list_old.push(...iteminfo_list_new);
            self.setData({
              iteminfo_list: iteminfo_list_old,
              item_flag: false
            })
          }
        }
        wx.hideLoading();
      }
    })
  },
  click_item(e) {
    // console.log(e);
    let item_current = e.currentTarget.dataset.item_current;
    this.setData({
      item_current: item_current,
    })
  },
  // item翻页
  itemChange(e) {
    // console.log(e);
    let item_current = parseInt(e.detail.current);
    wx.showLoading({
      title: '小主稍后~',
      mask: true,
    })
    switch (item_current) {
      case 0:
        var data_type = '';
        break;
      case 1:
        var data_type = 'hot';
        break;
      case 2:
        var data_type = 'new';
        break;
      case 3:
        var data_type = 'onlink';
        break;
      default:
        console.log("other")
    }
    this.setData({
      item_current: item_current,
      item_page: 1,
      data_type: data_type,
      item_flag: true,
      // itemInfo_list: [],
    })
    this.itemInfo(this.data.item_page, data_type)
  },
  //列表 swiper
  getSwiper(page) {
    var that = this;
    wx.request({
      url: app.globalData.url + 'api/timing/recruit/recommend/list',
      method: 'POST',
      data: {
        token: app.globalData.token,
        page: page,
      },
      success: (e) => {
        // console.log(e)
        if ((this.data.list_page > e.data.data.total_page) && (this.data.list_page == e.data.data.total_page)) {
          console.log('最后一页')
        } else {
          if (this.data.recruit_info_all == '') {
            //   console.log(1111111)
            var recruit_info_all = e.data.data.list;
            recruit_info_all.forEach((value, index, array) => {
              value.work_position = (value.work_position).split("-")[0] ? (value.work_position).split("-")[0] : value.work_position;
              value.publish_time = time.formatTimeTwo(value.publish_time, 'Y.M.D');
            })
          } else {
            //   console.log(2222222222222)
            var recruit_info_all_new = e.data.data.list,
              recruit_info_all = this.data.recruit_info_all;
            recruit_info_all_new.forEach((value, index, array) => {
              value.work_position = (value.work_position).split("-")[0] ? (value.work_position).split("-")[0] : value.work_position;
              value.publish_time = time.formatTimeTwo(value.publish_time, 'Y.M.D');
            })
            recruit_info_all.push(...recruit_info_all_new);
          }
        }
        this.setData({
          recruit_info_all: recruit_info_all,
        })
        wx.hideLoading()
      }
    })
  },

  getTab() {
    wx.request({
      url: app.globalData.url + 'api/timing/applet/show',
      method: 'POST',
      success: (e) => {
        // console.log(e)
        let is_show = e.data.data.is_show,
          tel = wx.getStorageSync('reg_telephone');
        // if (tel == '18258151021') {
        if (is_show == app.globalData.tab_is_show) {
          this.setData({
            tabbar: {
              color: "#fff",
              selectedColor: "#d0a76c",
              backgroundColor: "#1b1b1b",
              borderStyle: "black",
              list: [{
                  pagePath: "../../../pages/industry/industry",
                  text: "行业",
                  iconPath: "../../../images/icon/icon_ind.png",
                  selectedIconPath: "../../../images/icon/icon_indS.png",
                  selected: false
                },
                {
                  pagePath: "../../../pages/mine/mine",
                  text: "我的",
                  iconPath: "../../../images/icon/icon_mine.png",
                  selectedIconPath: "../../../images/icon/icon_mineS.png",
                  selected: false
                }
              ],
              position: "bottom"
            },
          })
          this.editTabBar();
        } else {
          if (this.data.role == 2) {
            this.setData({
              tabbar: {
                color: "#fff",
                selectedColor: "#d0a76c",
                backgroundColor: "#1b1b1b",
                borderStyle: "black",
                list: [{
                    pagePath: "../../../pages/recruit/index/index",
                    text: "招聘",
                    iconPath: "../../../images/icon/icon_rec.png",
                    selectedIconPath: "../../../images/icon/icon_recS.png",
                    selected: true
                  },
                  {
                    pagePath: "../../../pages/earns/earns",
                    text: "赚钱",
                    iconPath: "../../../images/icon/icon_money.png",
                    selectedIconPath: "../../../images/icon/icon_moneyS.png",
                    selected: false
                  },
                  {
                    pagePath: "../../../pages/industry/industry",
                    text: "行业",
                    iconPath: "../../../images/icon/icon_ind.png",
                    selectedIconPath: "../../../images/icon/icon_indS.png",
                    selected: false
                  },
                  {
                    pagePath: "../../../pages/mine/mine",
                    text: "我的",
                    iconPath: "../../../images/icon/icon_mine.png",
                    selectedIconPath: "../../../images/icon/icon_mineS.png",
                    selected: false
                  }
                ],
                position: "bottom"
              },
            })
          } else {
            this.setData({
              tabbar: {
                color: "#fff",
                selectedColor: "#d0a76c",
                backgroundColor: "#1b1b1b",
                borderStyle: "black",
                list: [{
                    pagePath: "../../../pages/recruit/index/index",
                    text: "招聘",
                    iconPath: "../../../images/icon/icon_rec.png",
                    selectedIconPath: "../../../images/icon/icon_recS.png",
                    selected: true
                  },
                  {
                    pagePath: "../../../pages/industry/industry",
                    text: "行业",
                    iconPath: "../../../images/icon/icon_ind.png",
                    selectedIconPath: "../../../images/icon/icon_indS.png",
                    selected: false
                  },
                  {
                    pagePath: "../../../pages/mine/mine",
                    text: "我的",
                    iconPath: "../../../images/icon/icon_mine.png",
                    selectedIconPath: "../../../images/icon/icon_mineS.png",
                    selected: false
                  }
                ],
                position: "bottom"
              },
            })
          }
          this.editTabBar();
        }
      },
    })
  },
  //切换tabbar的方法  
  editTabBar: function() {
    var tabbar = this.data.tabbar,
      currentPages = getCurrentPages(),
      _this = currentPages[currentPages.length - 1],
      pagePath = _this.__route__;
    (pagePath.indexOf('/') != 0) && (pagePath = '/' + pagePath);
    for (var i in tabbar.list) {
      // tabbar.list[i].selected = false;
      (tabbar.list[i].pagePath == pagePath) && (tabbar.list[i].selected = true);
    }
    _this.setData({
      tabbar: tabbar
    });
    // console.log(tabbar)
  },
  //关闭当天领取
  today_close() {
    this.isToday(0);
  },
  go_today() {
    this.isToday(1);
    wx.showToast({
      title: '领取成功',
      icon: 'none'
    })
  },
  //是否点击当天领取
  isToday(type) {
    wx.request({
      url: app.globalData.url + 'api/login/gives/get',
      data: {
        token: app.globalData.token,
        type: type,
      },
      method: 'POST',
      success: (e) => {
        this.modal_hide();
      }
    })
  },
  // 是否要升级
  get_isupdate() {
    wx.request({
      url: app.globalData.url + 'api/broker/hand/upgrade/alert',
      data: {
        token: app.globalData.token,
      },
      method: 'POST',
      success: (e) => {
        console.log(e)
        let updateInfo = e.data.data,
          flag_update = e.data.data.is_upgrade == 1 ? true : false;
        this.setData({
          updateInfo: updateInfo,
          flag_update: flag_update,
        })

      },
    })
  },
  //是否弹出赠送好礼
  isAppear() {
    wx.request({
      url: app.globalData.url + 'api/login/pop/gives',
      data: {
        token: app.globalData.token,
      },
      method: 'POST',
      success: (e) => {
        console.log(e)
        let flag_today = (e.data.data.is_pop == 1) ? true : false;
        let gives = e.data.data.gives;
        this.setData({
          flag_today: flag_today,
          gives: gives,
        })
      }
    })
  },
  //去升级
  go_update() {
    this.get_isupdate();
    wx.navigateTo({
      url: '../../mine/anchorWelfare/upgrade/upgrade'
    })
  },
  //切换注册
  click_tap() {
    this.setData({
      flag_redBag: true
    })
    this.invitation_alert(1);
  },
  //七日收益
  earns() {
    wx.request({
      url: app.globalData.url + 'api/task/seven/day/earnings',
      data: {
        token: app.globalData.token
      },
      method: 'POST',
      success: (e) => {
        let earnsInfo = e.data.data.earnings;
        var xInfo = [],
          yInfo = [];
        earnsInfo.forEach(function(value, index) {
          var str = value.show_date;
          var str_new = str.replace(/"-"/, ".");
          var str_re = str_new.substring(5);
          value.show_date = str_re;
          value.operate_num = parseInt(value.operate_num);
          xInfo.push(value.show_date);
          yInfo.push(value.operate_num)
        })
        // outSide.xInfo = xInfo;
        // outSide.yInfo = yInfo;
        wx.setStorageSync('xInfo', xInfo)
        wx.setStorageSync('yInfo', yInfo)

        // console.log(outSide.xInfo)
        // console.log(outSide.yInfo)
      }
    })
  },
  //去福利页
  go_welfare() {
    this.earns();
    if (this.data.role == "1") {
      this.setData({
        flag_first: false,
      })
      wx.navigateTo({
        url: '../../payment/bodou/index',
      })
    } else if (this.data.role == "2") {
      this.setData({
        flag_first: false,
      })
      wx.navigateTo({
        url: '../../mine/anchorWelfare/anchorWelfareRe',
      })
    } else {
      console.log("other")
    }

  },
  //列表移动
  listMove(e) {
    console.log(e)
  },
  //列表起手
  listStart(e) {
    // console.log(e)
    var clientY = e.changedTouches["0"].clientY;
    this.setData({
      pro_clientY: clientY,
    })
  },
  listEnd(e) {
    // console.log(e)
    // var clientY = e.changedTouches["0"].clientY,
    //   pro_clientY = this.data.pro_clientY;
    // console.log(clientY - pro_clientY)
    // if (clientY - pro_clientY > 0) {
    //   this.setData({
    //     shwo_redBag: true
    //   })
    // } else {
    //   this.setData({
    //     shwo_redBag: false
    //   })
    // }
  },
  //列表滚动
  // listScroll(e) {
  // console.log(e)
  // var scrollTop = e.detail.scrollTop;
  // if (scrollTop > 280) {
  //   var flag_stick = true;
  // } else {
  //   var flag_stick = false;
  // }
  // if (scrollTop)
  //   this.setData({
  //     flag_stick: flag_stick,
  //   })
  // },
  //去充值
  go_recharge() {
    this.setData({
      flag_find_anchor_call_bodou_no: true,
    })
    wx.navigateTo({
      url: '../../payment/bodou/index',
    })
  },
  //加载导航
  navList() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/timing/anchor/recruit/list',
      data: {},
      method: 'POST',
      success: function(e) {
        // console.log(e)
        let navInfo = e.data.data.list;
        that.setData({
          navInfo: navInfo,
        })
      },
    })
  },
  //导航选择 所有
  select_nav(e) {
    // console.log(e)
    if (wx.getStorageSync('token') == '') {
      wx.showModal({
        content: '登录后才能看详情哦~',
        showCancel: true,
        cancelColor: '#333',
        confirmText: '登录',
        confirmColor: '#d0a76c',
        success: function(e) {
          if (e.confirm) {
            wx.redirectTo({
              url: '../../author/author',
            })
          }
        },
      })
    } else {
      let anchor_type = e.currentTarget.dataset.anchor_type,
        type = (e.currentTarget.dataset.type).toString();
      switch (type) {
        case "1":
          wx.navigateTo({
            url: '../single/single?flag=all',
          })
          break;
        case "2":
          wx.navigateTo({
            url: '../single/single?flag=sift&anchor_type=' + anchor_type,
          })
          break;
        case "3":
          wx.navigateTo({
            url: '../single/single?flag=official',
          })
          break;
        case "4":
          wx.navigateTo({
            url: '../single/single?flag=special',
          })
          break;
        default:
          // console.log("none")
      }
    }

  },
  select_all() {
    wx.navigateTo({
      url: '../single/single?flag=all',
    })
  },
  select_sift() {
    wx.navigateTo({
      url: '../single/single?flag=sift',
    })
  },
  select_official() {
    wx.navigateTo({
      url: '../single/single?flag=official',
    })
  },
  select_special() {
    wx.navigateTo({
      url: '../single/single?flag=special',
    })
  },
  getcount() {
    wx.request({
      url: app.globalData.url + 'api/swop/guild/number',
      data: {
        token: app.globalData.token
      },
      method: 'POST',
      success: (e) => {
        let count = e.data.data.count,
          all_total = e.data.data.all_total;
        // console.log('count=' + count)
        this.setData({
          count: count,
          all_total: all_total,
        })
      },
    })
  },
  talk_close: function() {
    this.setData({
      qiang: false
    })
  },
  //抢主播支付波豆
  payBdQZB(resume_id, type, active_id, price) {
    wx.request({
      url: app.globalData.url + 'api/resume/guild/grab/anchor/order',
      data: {
        token: app.globalData.token,
        resume_id: resume_id,
        type: type,
        active_id: active_id,
        price: price
      },
      method: 'POST',
      dataType: 'json',
      responseType: 'text',
      success: (e) => {
        // console.log(e)
        this.setData({
          qiang: false
        })
        var chat_id = e.data.data.chat_id;
        wx.navigateTo({
          url: '../session/index?chat_id=' + chat_id + '&title=直播之家'
        })
      },
    })
  },
  //点击抢主播
  clickQzb(e) {
    console.log(e)
    let active_id = e.currentTarget.dataset.active_id ? e.currentTarget.dataset.active_id : "",
      is_activity = e.currentTarget.dataset.is_activity ? e.currentTarget.dataset.is_activity : "",
      talk_resume_id = e.currentTarget.dataset.talk_resume_id ? e.currentTarget.dataset.talk_resume_id : "",
      usable_bd = e.currentTarget.dataset.usable_bd ? parseInt(e.currentTarget.dataset.usable_bd) : "",
      xf_bd = e.currentTarget.dataset.xf_bd ? parseInt(e.currentTarget.dataset.xf_bd) : "",
      g_price = e.currentTarget.dataset.g_price ? parseInt(e.currentTarget.dataset.g_price) : "",
      activityinfo = e.currentTarget.dataset.activityinfo,
      activity = e.currentTarget.dataset.activity;
    this.setData({
      qiang: false
    })
    if (is_activity == 1) {
      //活动状态
      if (usable_bd > g_price) {
        this.payBdQZB(talk_resume_id, is_activity, active_id, g_price);
      } else {
        this.setData({
          flag_find_anchor_call_bodou_no: false
        })
      }
    } else {
      //非活动状态
      if (usable_bd > xf_bd) {
        this.payBdQZB(talk_resume_id, is_activity, 0, xf_bd);
      } else {
        this.setData({
          flag_find_anchor_call_bodou_no: false
        })
      }
    }
  },
  getQZB(resume_id) {
    wx.request({
      url: app.globalData.url + 'api/resume/guild/grab/anchor',
      data: {
        token: app.globalData.token,
        resume_id: resume_id,
      },
      method: 'POST',
      dataType: 'json',
      responseType: 'text',
      success: (e) => {
        console.log(e)
        let activityInfo = e.data.data,
          activity = e.data.data.activity;
        this.setData({
          activityInfo: activityInfo,
          activity: activity
        })
      },
    })
  },
  //点击约聊
  click_session(e) {
    //   console.log(e.currentTarget.dataset.resume_id);

    // 连续点击判断 Start
    var session_flag = this.data.session_flag,
      session_time = this.data.session_time;
    if (this.data.session_flag == true) {
      this.setData({
        session_flag: false,
      })
      var timer = setTimeout(() => {
        this.setData({
          session_flag: true,
        })
      }, 1500)
      //连续点击判断 End

      // console.log('ok')
      let resume_id = e.currentTarget.dataset.resume_id,
        is_issue = this.data.is_issue,
        residue_num = this.data.residue_num,
        nickname = e.currentTarget.dataset.nickname,
        is_chat = e.currentTarget.dataset.is_chat,
        is_rob = e.currentTarget.dataset.is_rob;
      this.getQZB(resume_id);
      if (this.data.is_issue == 0) {
        //未发布
        this.setData({
          flag_find_anchor_nojob: false,
        })
      } else if (is_issue == "2" && residue_num == "0") {
        this.setData({
          flag_find_anchor_jobing: false,
        })
      } else {
        if (is_rob == 1) {
          this.session(resume_id, nickname);
        } else {
          this.setData({
            qiang: true
          })
          // console.log(e)
          let nickname = e.currentTarget.dataset.nickname,
            type_name = e.currentTarget.dataset.type_name;
          this.setData({
            talk_nickname: nickname,
            talk_type_name: type_name,
            talk_resume_id: resume_id,
          })
        }
      }
    } else {
      //多次点击
    }




  },
  session(resume_id, nickname) {
    wx.request({
      url: app.globalData.url + 'api/guild/chat/anchor',
      data: {
        token: app.globalData.token,
        resume_id: resume_id,
        type: 1,
      },
      method: 'POST',
      success: (e) => {
        console.log(e)
        var chat_id = e.data.data.chat_id;
        wx.navigateTo({
          url: '../session/index?chat_id=' + chat_id + '&title=' + nickname
        })
        // other.chat_id = e.data.data.chat_id
      }
    })
  },
  //点击主播收藏
  click_anchor_col(e) {
    let that = this;
    let resume_id = e.currentTarget.dataset.resume_id;
    let index = e.currentTarget.dataset.resumesindex;
    let resumes = this.data.resumes;

    if (resumes[index].is_collect == 1) {
      //已收藏
      wx.showToast({
        title: '取消收藏成功',
        icon: 'none',
      })
      resumes[index].is_collect = "0";
      this.setData({
        resumes: resumes,
      })
      this.anchor_col_no(resume_id);
    } else {
      //未收藏
      wx.showToast({
        title: '收藏成功',
        icon: 'none',
      })
      resumes[index].is_collect = "1";
      this.setData({
        resumes: resumes,
      })
      this.anchor_col(resume_id);
    }

    // console.log(e)
  },
  //收藏操作
  anchor_col(resume_id) {
    wx.request({
      url: app.globalData.url + 'api/resume/do/collect',
      data: {
        token: app.globalData.token,
        resume_id: resume_id
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
      },
    })
  },
  //取消收藏操作
  anchor_col_no(resume_id) {
    wx.request({
      url: app.globalData.url + 'api/resume/cancel/collect',
      data: {
        token: app.globalData.token,
        resume_id: resume_id
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
      },
    })
  },
  //点击刷新
  click_fresh() {
    wx.showLoading()
    let timer = setTimeout(function() {
      wx.hideLoading();
      clearTimeout(timer);
    }, 1000)
    this.setData({
      flag_index: 0,
      anchor_page: 1,
      resumes: [], //所有
      resumes_odd: [], //奇数
      resumes_even: [], //偶数
    })
    this.get_anchorInfo(1);
  },
  //单独页
  single_change(e) {
    // console.log(e)
    // this.setData({
    //   mini_index: e.detail.current
    // })
  },

  //去购买
  click_buy() {
    this.setData({
      flag_find_anchor_call_no: true,
    })
    wx.navigateTo({
      url: '../../payment/index/index',
    })
  },

  //stay_anchor
  stay_anchor(e) {
    let that = this;
    this.get_phone();
    console.log(e)
    let resume_id = e.currentTarget.dataset.resume_id,
      is_linkup = e.currentTarget.dataset.is_linkup,
      resumesindex = e.currentTarget.dataset.resumesindex,
      re_number = this.data.re_number,
      bodou = e.currentTarget.dataset.bodou,
      resumes = this.data.resumes,
      register_all = this.data.register_all,
      hf_bd2 = parseInt(this.data.hf_bd2),
      hf_bd = parseInt(this.data.hf_bd);
    let phone = this.data.after_telephone ? this.data.after_telephone : this.data.reg_telephone;

    if (is_linkup == "1") {
      that.setData({
        flag_find_anchor_stay: true,
        flag_find_anchor_stay_no: true,
      })
      wx.showToast({
        title: '您已对该主播留过电话',
        icon: 'none',
      })
    } else {
      if (bodou) {
        if ((parseInt(register_all.bd) < hf_bd2) || (parseInt(register_all.bd) < hf_bd)) {
          this.setData({
            flag_find_anchor_call_bodou_no: false,
            flag_find_anchor_stay: true,
            flag_find_anchor_stay_no: true,
          })
        } else {
          this.get_residue_time(2, resume_id, phone, hf_bd2);
          this.get_residue_time(1);
          this.get_is_issue();
          resumes[resumesindex].is_linkup = 1;
          that.setData({
            flag_find_anchor_stay: true,
            resumes: resumes,
          })
          wx.showToast({
            title: '操作成功~',
            icon: 'none',
          })
        }

      } else {
        if (re_number > 0) {
          //有 留电话次数
          this.get_residue_time(2, resume_id, phone);
          this.get_residue_time(1);
          resumes[resumesindex].is_linkup = 1;
          that.setData({
            flag_find_anchor_stay: true,
            flag_find_anchor_stay_no: true,
            resumes: resumes,
          })
          wx.showToast({
            title: '操作成功~',
            icon: 'none',
          })
        } else {
          //没有 留电话次数
          this.setData({
            flag_find_anchor_call_bodou_no: false,
            flag_find_anchor_stay: true,
          })
        }
      }
    }
    // flag_find_anchor_stay_no
  },
  //输入预留手机号
  inp_find_anchor(e) {
    // console.log(e.detail.value)
    this.setData({
      after_telephone: e.detail.value,
    })
  },
  //默认手机号
  get_phone() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/common/register/info',
      data: {
        token: app.globalData.token,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e.data.data.register_info.telephone)
        let telephone = e.data.data.register_info.telephone;
        that.setData({
          register_all: e.data.data,
          register_info: e.data.data.register_info,
          reg_telephone: telephone
        })
      },
    })
  },

  // 已获得权限 拨打电话
  gets_call(e) {
    let resume_id = e.currentTarget.dataset.resume_id,
      is_linkup = e.currentTarget.dataset.is_linkup,
      telephone = e.currentTarget.dataset.telephone,
      resumesindex = e.currentTarget.dataset.resumesindex,
      resumes = this.data.resumes,
      hf_bd = this.data.hf_bd;

    wx.makePhoneCall({
      phoneNumber: telephone,
      success(e) {
        // console.log(e.errMsg == 'makePhoneCall:ok')
      }
    })
  },
  go_resume_list() {
    wx.navigateTo({
      url: '../deliveryList/deliveryList?currentData=2'
    })
  },

  //点击减少找主播 播豆电话次数 get power
  reduce_gets(e) {
    let resume_id = e.currentTarget.dataset.resume_id,
      is_linkup = e.currentTarget.dataset.is_linkup,
      telephone = e.currentTarget.dataset.telephone,
      resumesindex = e.currentTarget.dataset.resumesindex,
      resumes = this.data.resumes,
      hf_bd = this.data.hf_bd;
    if (is_linkup == "1") {
      this.setData({
        flag_resume_list: false
      })
    } else {
      this.reduseBd(resume_id, hf_bd);
      this.link_up_anchor(0, resume_id)
      this.get_residue_time(1);
      this.get_phone();
      this.get_is_issue();
      this.setData({
        flag_resume_list: false
      })
    }
    resumes[resumesindex].is_linkup = 1;
    this.setData({
      resumes: resumes,
      flag_find_anchor_call_bodou: true
    })
  },

  //点击减少找主播 的电话次数
  reduce_callnum(e) {
    // console.log(e)
    let resume_id = e.currentTarget.dataset.resume_id,
      is_linkup = e.currentTarget.dataset.is_linkup,
      telephone = e.currentTarget.dataset.telephone,
      resumesindex = e.currentTarget.dataset.resumesindex,
      resumes = this.data.resumes;
    if (is_linkup == "1") {
      wx.makePhoneCall({
        phoneNumber: telephone,
        success(e) {
          // console.log(e.errMsg == 'makePhoneCall:ok')
        }
      })
    } else {
      this.residue(resume_id);
      this.link_up_anchor(0, resume_id)
      this.get_residue_time(1);
      this.get_is_issue();
      wx.makePhoneCall({
        phoneNumber: telephone,
        success(e) {
          // console.log(e.errMsg =='makePhoneCall:ok')
        }
      })
    }
    resumes[resumesindex].is_linkup = 1;
    this.setData({
      resumes: resumes
    })
    // this.setData({
    //   flag_find_anchor_call: true,
    // })
    // this.residue(resume_id);
  },
  residue(resume_id) {
    wx.request({
      url: app.globalData.url + 'api/recruit/buy/residue/number',
      data: {
        token: app.globalData.token,
        resume_id: resume_id,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
      },

    })
  },

  //会长主动沟通主播
  link_up_anchor(anchor_id, resume_id) {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/guild/driving/link/up/anchor',
      data: {
        token: app.globalData.token,
        anchor_id: anchor_id,
        resume_id: resume_id,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
      },
    })
  },

  //phone_fix
  phone_fix() {
    this.setData({
      focus: true,
    })
  },

  //找主播打电话
  click_anchor_call(e) {
    console.log(e)
    let that = this;
    this.get_phone();
    // this.get_is_issue();
    // this.get_residue_time(1);

    let is_issue = this.data.is_issue,
      residue_num = this.data.residue_num,
      re_number = this.data.re_number,
      bd = parseInt(this.data.register_all.bd),
      resume_id = e.currentTarget.dataset.resume_id,
      is_linkup = e.currentTarget.dataset.is_linkup,
      stay = e.currentTarget.dataset.stay,
      resumesindex = e.currentTarget.dataset.resumesindex,
      is_sign = e.currentTarget.dataset.is_sign;
    // console.log('re_number+' + re_number)
    // console.log('this.data.re_number+' + this.data.re_number)

    that.setData({
      resumesindex: resumesindex,
      is_linkup: is_linkup,
    })
    if (is_sign == 2) {
      //已经签约
      if (is_issue == "0") {
        //没发布过
        that.setData({
          flag_find_anchor_nojob: false,
        })
        this.get_residue_time(1);
        this.get_is_issue();
        // console.log(1)
      } else if (is_linkup == "1" && stay) {
        wx.showToast({
          title: '您已对该主播留过电话',
          icon: 'none',
        })
      } else if (is_issue == "2" && residue_num == "0") {
        that.setData({
          flag_find_anchor_jobing: false,
        })
      } else {
        if (e.currentTarget.dataset.telephone) {
          // 存在电话 拨打电话
          if (residue_num >= 0) {
            console.log(bd)
            if (bd >= this.data.hf_bd) {
              that.setData({
                flag_find_anchor_call_bodou: false,
              })
            } else {
              console.log(1111111111)
              console.log(bd)
              console.log(this.data.hf_bd)
              that.setData({
                flag_find_anchor_call_bodou_no: false,
              })
            }
            // that.setData({
            //   flag_find_anchor_call_no: false,
            // })
            this.get_residue_time(1);
            this.get_is_issue();
            // console.log(2)
          } else {
            that.setData({
              flag_find_anchor_call: false,
            })
            this.get_residue_time(1);
            this.get_is_issue();
            // console.log(3)
          }
        } else {
          // 留电话
          if (re_number > 0) {
            that.setData({
              flag_find_anchor_stay: false,
            })
            this.get_residue_time(1);
            this.get_is_issue();
            // console.log(4)
          } else if (is_issue == "2" && re_number == 0) {
            wx.showToast({
              title: '职位正在审核中',
              icon: 'none',
            })
          } else if (parseInt(this.data.register_all.bd) > this.data.hf_bd2) {
            that.setData({
              flag_find_anchor_stay_no: false,
            })
            this.get_residue_time(1);
            this.get_is_issue();
          } else if (this.data.hf_bd2 >= parseInt(this.data.register_all.bd)) {
            this.setData({
              flag_find_anchor_call_bodou_no: false,
            })
          } else {
            console.log('其他情况')
            // that.setData({
            //   flag_find_anchor_stay_no: false,
            // })
            // this.get_residue_time(1);
            // this.get_is_issue();
          }
        }
      }
    } else {
      wx.showToast({
        title: '该主播已签约公会',
        icon: 'none',
      })
    }

  },
  //扣除播豆
  reduseBd(resume_id, bd_num) {
    wx.request({
      url: app.globalData.url + 'api/recruit/buy/residue/number',
      data: {
        token: app.globalData.token,
        resume_id: resume_id,
        bd_num: bd_num,
      },
      method: 'POST',
      success: (e) => {
        console.log(e)
      },
    })
  },
  //加载是否 发布过
  get_is_issue() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/guild/company/add',
      data: {
        token: app.globalData.token,
        type: "2",
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
        let is_issue = e.data.data.company.is_issue;
        let residue_num = e.data.data.company.residue_num,
          hf_bd2 = e.data.data.company.hf_bd2,
          hf_bd = e.data.data.company.hf_bd;
        that.setData({
          is_issue: is_issue,
          residue_num: residue_num,
          hf_bd2: hf_bd2,
          hf_bd: hf_bd,
        })
      },
    })
  },

  //会长给主播留电话     查看剩余次数 && 留电话
  get_residue_time(is_leave, resume_id, telephone, bd_num) {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/recruit/guild/leave/anchor',
      data: {
        token: app.globalData.token,
        is_leave: is_leave,
        resume_id: resume_id,
        telephone: telephone,
        bd_num: bd_num,
      },
      method: 'POST',
      success: function(e) {
        let re_number = e.data.data.re_number;
        that.setData({
          re_number: re_number,
        })
      },
    })
  },

  //列表 下滑加载
  list_load(e) {
    // console.log(e)
    // console.log(this.data.recruit_info.length)

    let that = this;
    if (e.detail.source == "touch") {
      //防止swiper控件卡死
      if (this.data.current == 0 && this.data.preIndex > 1) { //卡死时，重置current为正确索引
        //主逻辑 Start
        let list_page = this.data.list_page,
          current_NOW = e.detail.current;
        this.setData({
          current_NOW: current_NOW,
        })

        let current = e.detail.current + 1;
        if (current == this.data.recruit_info.length) {
          list_page = list_page + 1;
          that.setData({
            list_page: list_page
          })
          this.list_list();
        }
        //主逻辑 End
        this.setData({
          current: this.data.preIndex
        });
      } else { //正常轮转时，记录正确页码索引
        //主逻辑 Start
        let list_page = this.data.list_page,
          current_NOW = e.detail.current;
        this.setData({
          current_NOW: current_NOW,
        })

        let current = e.detail.current + 1;
        if (current == this.data.recruit_info.length) {
          list_page = list_page + 1;
          that.setData({
            list_page: list_page
          })
          this.list_list();
        }
        //主逻辑 End
        this.setData({
          preIndex: current_NOW
        });
      }
    }

    //主逻辑 Start
    // let list_page = this.data.list_page,
    //   current_NOW = e.detail.current;
    // this.setData({
    //   current_NOW: current_NOW,
    // })

    // let current = e.detail.current + 1;
    // if (current == this.data.recruit_info.length) {
    //   list_page = list_page + 1;
    //   that.setData({
    //     list_page: list_page
    //   })
    //   this.list_list();
    // }
    //主逻辑 End
  },
  list_list() {
    let that = this;
    let list_page = this.data.list_page
    // this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.list_page, this.data.offset, this.data.recommend_new);
    // that.get_listInfo(list_page);
    this.getSwiper(list_page)
    wx.showLoading({
      icon: 'none',
    })
  },

  //找主播 下滑加载
  anchor_load(e) {
    let that = this;
    if (e.detail.source == "touch") {
      //防止swiper控件卡死
      if (this.data.current == 0 && this.data.preIndex > 1) { //卡死时，重置current为正确索引
        // 主逻辑Start
        let anchor_page = this.data.anchor_page;
        let current = e.detail.current + 1;
        if (current == this.data.resumes.length) {
          anchor_page = anchor_page + 1;
          that.setData({
            anchor_page: anchor_page
          })
          this.list();
        }
        // 主逻辑End
        this.setData({
          current: this.data.preIndex
        });
      } else { //正常轮转时，记录正确页码索引
        // 主逻辑Start
        let anchor_page = this.data.anchor_page;
        let current = e.detail.current + 1;
        if (current == this.data.resumes.length) {
          anchor_page = anchor_page + 1;
          that.setData({
            anchor_page: anchor_page
          })
          this.list();
        }
        // 主逻辑End
        this.setData({
          preIndex: current
        });
      }
    }

  },
  list() {
    let that = this;
    let anchor_page = this.data.anchor_page
    that.get_anchorInfo(1);
    wx.showLoading({
      icon: 'none',
    })
  },
  //得到 主播信息  推荐
  get_anchorInfo(data_type) {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/resume/recommend/list',
      data: {
        token: app.globalData.token,
        page: this.data.anchor_page,
        data_type: data_type,
      },
      method: 'POST',
      success: function(e) {
        console.log(e)
        let ori_resumes = that.data.resumes;
        let resumes = e.data.data.list;
        let resumes_odd = that.data.resumes_odd; //奇数
        let resumes_even = that.data.resumes_even; //偶数
        // console.log(resumes[0]);
        if (e.data.data.current_page > e.data.data.total_page) {
          // console.log("到底了");
          wx.hideLoading();
          wx.showToast({
            title: '到底啦~',
            icon: 'none',
          })
        } else {
          if (that.data.anchor_page == 1) {
            //无变化
            that.setData({
              resumes: resumes,
            })
          } else {
            ori_resumes.push(...resumes);
            that.setData({
              resumes: ori_resumes,
            })
          }
          wx.hideLoading();
        }
      },
    })
  },


  //去找主播详情页面
  go_discover(e) {
    // console.log(e.currentTarget.dataset.id)
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../discoverAnchor/discoverAnchor?id=' + id,
    })
  },

  //显示看主播
  click_lookAnchor() {
    let that = this;
    if (this.data.flag_falls) {
      // console.log("找主播")
      // if (!(this.data.item_flag)) {
      //   this.setData({
      //     nolike: 1,
      //     flag_list: true,
      //     mark_falls: true
      //   })
      // } wwx:
      that.setData({
        flag_falls: false,
        flag_float: true,
        mark_falls: false,
        flag_list: false,
        // nolike: 2,
      })
    } else {
      // console.log("看职位")
      if (!(this.data.item_flag)) {
        this.setData({
          nolike: 1,
          flag_list: true,
          mark_falls: true
        })
      }
      that.setData({
        flag_falls: true,
        flag_float: true,
        mark_falls: true,
        flag_list: true,
        // nolike:2,
      })
    }

  },
  //跳转不考虑页面
  go_notConsider() {
    wx.navigateTo({
      url: '../notConsider/notConsider',
    })
  },
  //浮动 点击 Start
  click_more: function() {
    let that = this;
    that.setData({
      flag_float: false,
    })
  },
  click_fList: function() {
    let that = this;
    // that.setData({
    //   orign_num:15
    // })

    if (this.data.is_last) {
      //区分是否是最后一页
      that.setData({
        flag_float: true,
        nolike: "1",
        card_page: 0,
      })
      //发送请求
      this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.card_page, offset, this.data.recommend_new);

    } else {
      if (that.data.move_card) {
        var offset = Math.abs(this.data.orign_num - this.data.now_num - this.data.not_consider);
      } else {
        var offset = 0;
      }

      that.setData({
        flag_float: true,
        nolike: "1",
        card_page: that.data.card_page,
        offset: offset,
      })
      //发送请求
      this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.card_page, offset, this.data.recommend_new);

    }


    that.setData({
      orign_num: 0,
      now_num: 0,
    })
    wx.hideLoading();

  },
  click_fCard(e) {
    let that = this;
    that.setData({
      // recruit_info:[],
      flag_float: true,
      nolike: "2",
      card_page: that.data.card_page,
    })
    //发送请求
    this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.card_page, 0, this.data.recommend_new);
    var recruit_info = this.data.recruit_info;
    recruit_info.splice(1, parseFloat(this.data.offset))

    setTimeout(function() {
      that.setData({
        recruit_info: recruit_info,
      })
    }, 500)

    var timer = setTimeout(function() {
      that.setData({
        orign_num: that.data.recruit_info.length,
      })
      clearTimeout(timer)
      wx.hideLoading();
    }, 1000)

  },
  click_fArea: function() {
    let that = this;
    if (this.data.special == 1) {
      that.setData({
        flag_float: true,
        salary_type: '2,3',
        special: 2,
        flag_falls: true,
        mark_falls: true,
      })
    } else {
      that.setData({
        flag_float: true,
        salary_type: '',
        special: 1,
        flag_falls: true,
        mark_falls: true,
      })
    }

    //发送请求
    this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.recommend_new);
  },
  click_fCol: function() {
    let that = this;
    that.setData({
      flag_float: true,
    })
    wx.navigateTo({
      url: '../../mine/collection/collection',
    })
  },
  //浮动 点击 End
  // QQ/微信/邮箱
  click_info: function(e) {
    var that = this;
    // console.log(e.currentTarget.dataset.type)
    if (that.data.is_resume == 0) {
      that.setData({
        more_show: true,
        show_modalWrap: true,
        flag_out: false,
      })
    } else {
      this.setData({
        flag_info: false,
        show_modalWrap: true,
        flag_qq: false,
        flag_weixin: false,
        flag_email: false,
      })
      var _type = e.currentTarget.dataset.type;
      if (_type == "qq") {
        wx.setClipboardData({
          data: that.data.recruit_info[0].qq
        })
        this.setData({
          flag_qq: true,
        })
      } else if (_type == "weixin") {
        wx.setClipboardData({
          data: that.data.recruit_info[0].weixin
        })
        this.setData({
          flag_weixin: true,
        })
      } else if (_type == "email") {
        wx.setClipboardData({
          data: that.data.recruit_info[0].email
        })
        this.setData({
          flag_email: true,
        })
      } else {}
    }

  },
  //click_modalWrap
  click_modalWrap: function() {
    this.setData({
      show_modalWrap: true,
    })
  },
  //模态框 拨打
  click_phone: function() {
    //管理员、会长
    wx.makePhoneCall({
      phoneNumber: '0571-87081736',
    })
    this.setData({
      flag_contact: true,
    })
  },
  //模态框 复制
  click_modal_copy: function() {
    wx.setClipboardData({
      data: 'zhibozhijia888',
      success: function(e) {
        // wx.showToast({
        //   title: '复制成功',
        //   icon:'none'
        // })
      }
    })
  },

  //留电话
  click_call: function(e) {
    // console.log(e.currentTarget.dataset.contact_phone)
    var status = this.data.status,
      recruit_id = e.currentTarget.dataset.recruit_id;
    var that = this;
    if (wx.getStorageSync('token') == '') {
      wx.showModal({
        content: '登录后才能体验哦~',
        showCancel: true,
        cancelColor: '#333',
        confirmText: '登录',
        confirmColor: '#d0a76c',
        success: function(e) {
          if (e.confirm) {
            wx.redirectTo({
              url: '../../author/author',
            })
          }
        },
      })
    } else {
      if (wx.getStorageSync('reg_register_role') == 0) {
        this.setData({
          flag_id: false
        })
      } else {
        if (status == '-1') {
          that.setData({
            more_show: true,
            show_modalWrap: true,
            flag_out: false,
          })
        } else if (status == '0') {
          wx.showToast({
            title: '简历审核中，暂不能操作',
            icon: 'none',
          })
        } else if (status == '1') {
          this.setData({
            recruit_id: recruit_id,
          })
          this.call_time();
          this.pull_info();
          this.setData({
            recruit_phone: e.currentTarget.dataset.contact_phone,
          })
          if (this.data.role == 2) {
            this.setData({
              show_modalWrap: false,
            })
          } else {
            this.setData({
              flag_contact: false,
            })
          }
        } else if (status == '2') {
          wx.showToast({
            title: '简历审核失败，请重新上传',
            icon: 'none',
          })
        }
      }
    }

  },
  //不考虑
  click_consider: function(e) {
    if (wx.getStorageSync('token') == '') {
      wx.showModal({
        content: '登录后才能体验哦~',
        showCancel: true,
        cancelColor: '#333',
        confirmText: '登录',
        confirmColor: '#d0a76c',
        success: function(e) {
          if (e.confirm) {
            wx.redirectTo({
              url: '../../author/author',
            })
          }
        },
      })
    } else {
      if (wx.getStorageSync('reg_register_role') == 0) {
        this.setData({
          flag_id: false
        })
      } else {
        // console.log(this.data.recruit_id);
        let not_consider = this.data.not_consider;
        let recruit_id = e.currentTarget.dataset.recruit_id;
        this.setData({
          not_consider: not_consider + 1,
        })
        this.consider(recruit_id);
      }
    }
  },
  //收藏
  click_collection: function(e) {
    // console.log(e.currentTarget.dataset)
    if (wx.getStorageSync('token') == '') {
      wx.showModal({
        content: '登录后才能体验哦~',
        showCancel: true,
        cancelColor: '#333',
        confirmText: '登录',
        confirmColor: '#d0a76c',
        success: function(e) {
          if (e.confirm) {
            wx.redirectTo({
              url: '../../author/author',
            })
          }
        },
      })
    } else {
      if (wx.getStorageSync('reg_register_role') == 0) {
        this.setData({
          flag_id: false
        })
      } else {
        let that = this;
        let is_collect = e.currentTarget.dataset.is_collect;
        let index = e.currentTarget.dataset.index;
        let recruit_id = e.currentTarget.dataset.recruit_id;
        let items = this.data.recruit_info_all;

        if (is_collect == 0) {
          //去收藏
          items[index].is_collect = 1;
          this.collection(recruit_id);
        } else if (is_collect == 1) {
          //取消收藏
          items[index].is_collect = 0;
          this.not_collection(recruit_id);
        } else {}
        that.setData({
          recruit_info_all: items,
        })
      }
    }
  },
  //换一批
  click_next: function() {
    // console.log("dianjidaole")
    let that = this;
    that.setData({
      page: 1,
      clickLike: 1,
    })
    //发送请求
    this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.recommend_new);
    that.setData({
      clickLike: '',
    })
  },
  //动画 Start
  ani_right: function() {
    this.animation.rotate(5)
      .translate(500, -90)
      .opacity(.1)
      .step()
    this.setData({
      animation: this.animation.export()
    })
  },
  ani_left: function() {
    this.animation.rotate(5)
      .translate(-500, -90)
      .opacity(.1)
      .step()
    this.setData({
      animation: this.animation.export()
    })
  },
  ani_fresh: function() {
    this.animation
      .step({
        duration: 100,
        timingFunction: 'ease-out'
      })
    this.setData({
      animation: this.animation.export()
    })
  },
  //动画 End
  //不收藏
  not_collection(_recruit_id) {
    wx.request({
      url: app.globalData.url + 'api/recruit/cancel/collect',
      data: {
        token: app.globalData.token,
        recruit_id: _recruit_id,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
      },
    })
  },
  // 收藏
  collection(_recruit_id) {
    let that = this;
    wx.showToast({
      title: '已收藏',
      icon: 'none',
      duration: 500
    })

    let recruit_info = this.data.recruit_info;
    // recruit_info.shift();

    that.setData({
      recruit_info: recruit_info
    })

    //发起收藏请求
    wx.request({
      url: app.globalData.url + 'api/recruit/do/collect',
      data: {
        token: app.globalData.token,
        recruit_id: _recruit_id,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
        // wx.hideToast();
      },
    })
  },
  //卡片加载下一个
  loadNext() {
    let that = this;
    let recruit_info = this.data.recruit_info;
    recruit_info.shift();

    that.setData({
      recruit_info: recruit_info,
      now_num: recruit_info.length,
      move_card: true,
    })
    // console.log("now_num+" + this.data.now_num + "---orign_num" + this.data.orign_num)

    //发送请求
    if (this.data.recruit_info.length == 0) {
      //加页码
      var card_page = this.data.card_page;
      this.setData({
        card_page: card_page + 1,
      })
      // console.log("page+" + this.data.card_page)
      //发送请求
      this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.card_page, this.data.offset, this.data.recommend_new);
      var timer = setTimeout(function() {
        that.setData({
          orign_num: that.data.recruit_info.length,
        })
        clearTimeout(timer);
      }, 1000)

    } else {}
  },
  //考虑
  consider(_recruit_id) {
    let that = this;

    wx.showToast({
      title: '加载中~',
      icon: 'none',
      duration: 500
    })
    // console.log("prevent");
    // this.ani_fresh();

    let recruit_info = this.data.recruit_info;
    recruit_info.shift();

    that.setData({
      recruit_info: recruit_info
    })

    //发送请求
    if (this.data.recruit_info.length == 0) {
      //加页码
      let page = this.data.page;
      this.setData({
        page: page + 1,
      })
      //发送请求
      this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.recommend_new);
    } else {}

    //发起不考虑请求
    wx.request({
      url: app.globalData.url + 'api/recruit/no/like',
      data: {
        token: app.globalData.token,
        recruit_id: _recruit_id,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
        // wx.hideToast();
      },
    })
  },


  //卡片 Start
  card_start: function(e) {
    let that = this;
    // console.log('开始+' + e.touches["0"].pageX)
    this.setData({
      touch_startX: e.touches["0"].pageX,
      recruit_id: e.currentTarget.dataset.recruit_id,
    })
  },
  card_end: function(e) {
    let that = this;
    // console.log('结束+' + e.changedTouches["0"].pageX)
    this.setData({
      touch_endX: e.changedTouches["0"].pageX,
    })


    //左右滑动 事件
    if (this.data.touch_endX - this.data.touch_startX > 100) {
      // this.collection();
      this.loadNext();
    } else if (this.data.touch_endX - this.data.touch_startX < -100) {
      // this.consider();
      this.loadNext();
    } else {}
    // console.log(this.data.recruit_info)
  },
  //打电话确认
  call_sure: function() {
    let that = this;
    // console.log('判断+' + that.data.reg_true)
    if (that.data.reg_true == true) {
      wx.request({
        url: app.globalData.url + 'api/resume/send/succeed',
        method: 'POST',
        data: {
          token: app.globalData.token,
          type: 1,
          recruit_id: that.data.recruit_id,
          telephone: that.data.phone_value,
        },
        success: function(e) {
          // console.log(e)
          that.setData({
            flag_phone: true,
          })
          wx.showToast({
            title: '操作成功~',
            icon: "none",
          })
        }
      })
    } else {
      // console.log('失败')
      wx.showToast({
        title: '手机号格式错误~',
        icon: "none",
      })
    }
  },
  //输入 手机号码 input phone
  input_phone: function(e) {
    let that = this;
    console.log(e.detail.value)

    let str = e.detail.value;
    let reg = /^1[3|4|5|7|8|9][0-9]{9}$/;
    let flag = reg.test(str);
    // console.log(flag)
    if (flag) {
      that.setData({
        reg_true: true,
        phone_value: e.detail.value,
      })
    }
  },
  //剩余发布次数
  residue_time() {
    wx.request({
      url: app.globalData.url + 'api/recruit/limit/number',
      data: {
        token: app.globalData.token,
      },
      method: 'POST',
      success: (e) => {
        // console.log(e)
        let last_time = e.data.data.is_send;
        this.setData({
          last_time: last_time,
        })
      },
    })
  },
  //点击 发布职位
  click_frelease() {
    this.residue_time();
    var that = this;
    this.setData({
      flag_float: true,
      flag_find_anchor_nojob: true,
    });
    wx.request({
      url: app.globalData.url + 'api/guild/company/add',
      data: {
        token: app.globalData.token
      },
      method: 'POST',
      success: function(e) {
        if (e.data.data.company.is_perfect == 0) {
          wx.navigateTo({
            url: '../../mine/CompanyBasis/CompanyBasis?ProcessJudge=false',
          })
        } else {
          if (that.data.last_time <= 0) {
            wx.showModal({
              content: '职位发布数量已用完,暂不能发布新的职位',
              showCancel: false,
              confirmText: '好的',
              confirmColor: '#d0a76c',
            })
          } else {
            wx.navigateTo({
              url: '../postJob/postJob?home=true',
            })
          }

        }
      }
    })
  },
  //点击 弹窗留电话
  click_stay: function() {
    let that = this;
    var status = this.data.status;
    // if (that.data.is_resume == '0') {
    if (status == '-1') {
      that.setData({
        more_show: true,
        show_modalWrap: true,
        flag_out: false,
      })
    } else if (status == '0') {
      wx.showToast({
        title: '简历审核中，暂不能操作',
        icon: 'none',
      })
    } else if (status == '1') {
      that.setData({
        more_show: true,
        flag_phone: false,
        show_modalWrap: true,
      })
    } else if (status == '2') {
      wx.showToast({
        title: '简历审核失败，请重新上传',
        icon: 'none',
      })
    }

  },
  //主播拨打电话
  anchor_call() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/recruit/anchor/make/telephone',
      data: {
        token: app.globalData.token,
        recruit_id: this.data.recruit_id,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
      },
    })
  },
  //点击 弹窗打电话
  click_tel: function() {
    let that = this;
    if (that.data.is_resume == 0) {
      that.setData({
        more_show: true,
        show_modalWrap: true,
        flag_out: false,
      })
    } else {
      this.setData({
        more_show: true,
        show_modalWrap: true,
      })
      this.apply();
      this.anchor_call();
    }

  },
  //点击 弹窗发送卡片电话
  click_send: function() {
    this.pull_resume();
    let that = this;
    if (that.data.is_resume == 0) {
      that.setData({
        more_show: true,
        show_modalWrap: true,
        flag_out: false,
      })
    } else {
      wx.showLoading({
        title: '小主稍等~',
      })
      let that = this;
      // console.log(that.data.is_resume)
      that.pull_info();
      if (that.data.is_resume == '1') {
        //有简历
        wx.request({
          url: app.globalData.url + 'api/resume/send/succeed',
          data: {
            token: app.globalData.token,
            type: 2,
            recruit_id: that.data.recruit_id,
          },
          method: 'POST',
          success: (e) => {
            // console.log(e)
            let code = e.data.code;
            if (code == 0) {
              let chat_id = e.data.data.chat_id;
              if (chat_id != 0) {
                wx.navigateTo({
                  url: '../session/index?chat_id=' + chat_id
                })
              } else {
                wx.showToast({
                  title: '发送成功~',
                  icon: 'none',
                });
              }
              wx.hideLoading();
            } else {
              console.log("已投递该简历");
              wx.hideLoading();
            }
          },
        })

      } else if (that.data.is_resume == '0') {
        //没有简历
        that.setData({
          flag_out: false,
          show_modalWrap: true,
        })
        wx.hideLoading()
      } else {}
    }

  },
  //简历状态
  resumeStatus() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/resume/status',
      data: {
        token: app.globalData.token,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
        let status = e.data.data.status;
        that.setData({
          status: status
        })
      },
    })
  },
  //主播求职申请
  apply: function(e) {
    let that = this;
    //主播
    wx.request({
      url: app.globalData.url + 'api/recruit/anchor/make/call',
      method: 'POST',
      data: {
        token: app.globalData.token,
        recruit_id: this.data.recruit_id,
      },
      success: function(e) {
        // console.log(e)
        if (that.data.is_call == "1") {
          //is_call=1,直接打电话
          if (that.data.recruit_phone) {
            wx.makePhoneCall({
              phoneNumber: that.data.recruit_phone,
            })
          } else {
            wx.showToast({
              icon: "none",
              title: '联系方式更新中~',
            })
          }
        } else {
          //走原先流程
          if (that.data.number <= '0') {
            // console.log('您的次数已用完，请分享页面增加次数')
            that.setData({
              flag: false,
            })
          } else {
            //打电话
            if (that.data.recruit_phone) {
              wx.makePhoneCall({
                phoneNumber: that.data.recruit_phone,
              })
            } else {
              wx.showToast({
                icon: "none",
                title: '联系方式更新中~',
              })
            }
          }
        }

      }
    })
  },
  // 拨打次数
  call_time: function() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/recruit/anchor/make/call',
      data: {
        token: app.globalData.token,
        recruit_id: this.data.recruit_id,
      },
      method: 'POST',
      success: function(e) {
        // console.log(e)
        that.setData({
          is_call: e.data.data.is_call,
          is_linkup: e.data.data.is_linkup,
          number: e.data.data.number,
        })
      },
    })
  },
  //clear_num
  clear_num: function(e) {
    this.setData({
      phone_value: '',
    })
  },
  // 出道/确定
  click_out_sure: function(e) {
    this.setData({
      flag_out: true,
      more_show: true,
    })
    wx.navigateTo({
      url: '../../resume/uploadResume/uploadResume?detail=1',
    })
  },
  //画布点击发送
  click_canvas_send: function() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/resume/send/succeed',
      method: 'POST',
      data: {
        token: app.globalData.token,
        type: 2,
        recruit_id: that.data.recruit_id,
        image: that.data.send_base64,
      },
      success: function(e) {
        // console.log(e)
        that.setData({
          shape_show: true,
        })
        wx.showToast({
          title: '操作成功~',
          icon: 'none',
        })
      }
    })
  },
  //画布 Start
  canvasLoad: function() {
    let that = this;
    // console.log("ok");
    //画图
    const ctx = wx.createCanvasContext('shape');
    let name = that.data.nickname,
      age = that.data.age + '岁',
      phone = that.data.phone_value;

    wx.getSystemInfo({
      success: function(e) {
        const rpx = e.windowWidth / 375;
        // console.log(rpx)
        ctx.rect(0, 0, 510, 976)
        ctx.setFillStyle('white')
        ctx.fill();

        //图片
        ctx.drawImage(that.data.show_img1, 0, 0, 255 * rpx, 255 * rpx)
        ctx.drawImage(that.data.show_img2, 0, 267 * rpx, 121 * rpx, 121 * rpx)
        ctx.drawImage(that.data.show_img3, 134 * rpx, 267 * rpx, 121 * rpx, 121 * rpx)
        //文字
        ctx.font = '16rpx bold 微软雅黑';
        ctx.setFillStyle("#333");
        ctx.setTextAlign('center');
        ctx.fillText(name, 255 * rpx / 2, 410 * rpx);
        ctx.font = '12rpx 微软雅黑';
        ctx.setFillStyle("#999");
        ctx.fillText(age, 110 * rpx, 436 * rpx);
        //iocn
        if (that.data.sex == "1") {
          ctx.drawImage(that.data.show_girl, 130 * rpx, 422 * rpx, 13 * rpx, 15 * rpx);
        } else if (that.data.sex == "2") {
          ctx.drawImage(that.data.show_man, 130 * rpx, 422 * rpx, 13 * rpx, 15 * rpx);
        } else {}
        ctx.drawImage(that.data.show_phone, 68 * rpx, 447 * rpx, 13 * rpx, 15 * rpx);
        ctx.setFillStyle("#333");
        ctx.font = '14rpx bold 微软雅黑';
        ctx.fillText(phone, 135 * rpx, 460 * rpx);
        ctx.draw(true, function(e) {
          // console.log(e)
          //导出
          wx.canvasToTempFilePath({
            x: 0,
            y: 0,
            width: 255,
            height: 473,
            destWidth: 562,
            destHeight: 1076,
            canvasId: 'shape',
            success: function(res) {
              // console.log(res.tempFilePath)
              var image_base64 = wx.getFileSystemManager().readFileSync(res.tempFilePath, "base64")
              console.log(image_base64)
              that.setData({
                send_base64: image_base64,
              })
            }
          })
        });
      }
    })
  },
  //画布 End
  // 是否有简历
  pull_resume: function() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/recruit/link/up/list',
      method: 'POST',
      data: {
        token: app.globalData.token,
      },
      success: function(e) {
        console.log(e.data.data.is_resume)
        that.setData({
          is_resume: e.data.data.is_resume
        })
      }
    })
  },
  //取出简历信息
  pull_info: function() {
    let that = this;
    if (this.data.role == 2 && this.data.is_resume == 1) {
      // console.log('拉电话')
      //加载简历数据
      wx.request({
        url: app.globalData.url + 'api/resume/index',
        method: 'POST',
        data: {
          token: app.globalData.token,
        },
        success: function(e) {
          // console.log(e)
          if (e.data.data.resume.telephone != '') {
            that.setData({
              reg_true: true,
            })
          }
          that.setData({
            phone_value: e.data.data.resume.telephone,
            nickname: e.data.data.resume.nickname,
            age: e.data.data.resume.age,
            sex: e.data.data.resume.sex,
          })
        }
      });
    }
  },
  //取出照片
  pull_pic: function() {
    let that = this;
    //取出照片
    wx.request({
      url: app.globalData.url + 'api/resume/read/photo',
      method: "POST",
      data: {
        token: app.globalData.token,
      },
      success: function(e) {
        // console.log(e)
        var str1 = e.data.data.resume["0"].img_url,
          str2 = e.data.data.resume["1"].img_url,
          str3 = e.data.data.resume["2"].img_url;
        var reg = /http/g;

        var img1 = str1.replace(reg, 'https'),
          img2 = str2.replace(reg, 'https'),
          img3 = str3.replace(reg, 'https');
        that.setData({
          img1: img1,
          img2: img2,
          img3: img3,
        })
        wx.downloadFile({
          url: img1,
          success: function(e) {
            // console.log(e.tempFilePath)
            that.setData({
              show_img1: e.tempFilePath,
            })
          }
        })
        wx.downloadFile({
          url: img2,
          success: function(e) {
            // console.log(e.tempFilePath)
            that.setData({
              show_img2: e.tempFilePath,
            })
          }
        })
        wx.downloadFile({
          url: img3,
          success: function(e) {
            // console.log(e.tempFilePath)
            that.setData({
              show_img3: e.tempFilePath,
            })
          }
        })
        wx.downloadFile({
          url: 'https://www.zhibohome.net/images/resume/ic_man1.png',
          success: function(e) {
            // console.log(e.tempFilePath)
            that.setData({
              show_girl: e.tempFilePath,
            })
          }
        })
        wx.downloadFile({
          url: 'https://www.zhibohome.net/images/resume/ic_girl1.png',
          success: function(e) {
            // console.log(e.tempFilePath)
            that.setData({
              show_man: e.tempFilePath,
            })
          }
        })
        wx.downloadFile({
          url: 'https://www.zhibohome.net/images/resume/card_phone.png',
          success: function(e) {
            // console.log(e.tempFilePath)
            that.setData({
              show_phone: e.tempFilePath,
            })
          }
        })
      }
    })
  },
  invitation_alert(alert) {
    wx.request({
      url: app.globalData.url + 'api/invitation/alert',
      data: {
        token: app.globalData.token,
        alert: alert,
      },
      method: 'POST',
      success: (e) => {
        let get_bd = e.data.data.get_bd;
        this.setData({
          get_bd: get_bd,
        })
      }
    })
  },
  first_hide() {
    this.setData({
      flag_first: false,
    })
    this.invitation_alert(1);
  },
  //模块框 Start
  modal_hide: function() {
    this.setData({
      flag: true,
      flag_time: true,
      flag_share: true,
      flag_phone: true,
      shape_show: true,
      flag_out: true,
      flag_contact: true,
      flag_info: true,
      flag_float: true,

      // 升级
      flag_update: false,
      flag_today: false,

      //中间
      flag_first: false,

      // 右下
      flag_moreTag: false,

      flag_find_anchor_nojob: true,
      flag_find_anchor_call: true,
      flag_find_anchor_stay: true,
      flag_find_anchor_call_no: true,
      flag_find_anchor_stay_no: true,
      flag_find_anchor_jobing: true,
      flag_find_anchor_call_bodou_no: true,
      flag_find_anchor_call_bodou: true,
      flag_resume_list: true,


      plat_show: true,
      type_show: true,
      salary_show: true,
      cycle_show: true,
      area_show: true,
      recommend_show: true,
      mask_show: false,
      kong_show: true,
      idx: '',

      flag_id: true,

    })
  },
  //模块框 End



  //卡片 End


  //twoMore
  click_twoMore: function() {
    if (this.data.twoMore == '1') {
      this.setData({
        twoMore: '2',
      })
    } else {
      this.setData({
        twoMore: '1',
      })
    }
  },
  //click_oneMore
  click_oneMore: function() {
    if (this.data.oneMore == '1') {
      this.setData({
        oneMore: '2',
      })
    } else {
      this.setData({
        oneMore: '1',
      })
    }

  },
  //形象卡
  click_card: function(e) {
    // console.log(e);
    wx.navigateTo({
      url: '../../resume/uploadResume/uploadResume?title=我的形象',
    })
  },

  //禁止滚动
  preventTouchMove() {

  },
  //点击全国
  click_country: function() {
    this.setData({
      county: "全国",
      area_name: '',
    })
    this.open()
  },
  //跳转banner
  go_banner: function(e) {
    // console.log(e.currentTarget.dataset.deatil_id)
    if (e.currentTarget.dataset.type == "1") {
      wx.navigateTo({
        url: '../../recruit/detail/detail?deatil_id=' + e.currentTarget.dataset.deatil_id,
      })
    } else if (e.currentTarget.dataset.type == "2") {
      wx.navigateTo({
        url: '../../protocol/protocol?url=' + e.currentTarget.dataset.relation_url + '&&title=直播之家',
      })
    } else {}

  },
  // input_base_high
  input_base_high: function(e) {
    this.setData({
      baseindex: null,
      base_high: e.detail.value,
    })
  },
  // input_base_low
  input_base_low: function(e) {
    this.setData({
      baseindex: null,
      base_low: e.detail.value,
    })
  },
  // focus_expect_high
  input_expect_high: function(e) {
    // console.log(e.detail.value)
    this.setData({
      expectindex: null,
      pay_high: e.detail.value,
      expect_high: e.detail.value,
    })
  },
  // focus_expect_low
  input_expect_low: function(e) {
    this.setData({
      expectindex: null,
      pay_low: e.detail.value,
      expect_low: e.detail.value,
    })
  },
  //期望底薪
  click_base: function(e) {
    // console.log(e)
    // if (e.currentTarget.dataset.pay_low == '0') {
    //      var keep_pay = e.currentTarget.dataset.pay_high;
    // } else if (e.currentTarget.dataset.pay_high == '0') {
    //      var keep_pay = e.currentTarget.dataset.pay_low;
    // } else if (e.currentTarget.dataset.pay_high == '' && e.currentTarget.dataset.pay_low == '') {
    //      var keep_pay = '';
    // } else {
    //      var keep_pay = e.currentTarget.dataset.pay_low + '-' + e.currentTarget.dataset.pay_high;
    // }
    this.setData({
      baseindex: e.currentTarget.dataset.baseindex,
      keep_pay: e.currentTarget.dataset.keep_pay,
    })
    // console.log(keep_pay)
  },
  //期望薪资
  click_expect: function(e) {
    // console.log(e.currentTarget.dataset)
    this.setData({
      expectindex: e.currentTarget.dataset.expectindex,
      pay_low: e.currentTarget.dataset.pay_low,
      pay_high: e.currentTarget.dataset.pay_high,
      expect_low: null,
      expect_high: null,
    })
  },
  //工作方式
  click_jobId(e) {
    // console.log(e.currentTarget.dataset);
    let that = this;

    let jobindex = e.currentTarget.dataset.joblist_id - 1;
    that.setData({
      jobindex: jobindex,
    })
    if (this.data.jobindex == "0") {
      // console.log("线上")
      that.setData({
        job_method: "1",
      })
    } else if (this.data.jobindex == "1") {
      // console.log("线下")
      that.setData({
        job_method: "2",
      })
    } else {
      // console.log("全部")
      that.setData({
        jobindex: "-1",
        job_method: "4",
      })
    }


  },
  //选择结算周期
  click_time: function(e) {
    // console.log(e);
    if (e.currentTarget.dataset.timelistindex >= 0) {
      this.setData({
        timelistindex: null,
      })

      //点击除了全部
      let timeList = this.data.timeList;
      // console.log(this.data.timeList)
      let index = e.currentTarget.dataset.timelistindex;
      let item = timeList[index];
      item.isSelected = !item.isSelected;
      // console.log(item)
      //加入选择的主播类型
      let timelist_id = e.currentTarget.dataset.timelist_id;
      let salary_type = this.data.salary_type;
      if (this.data.salary_type == "") {
        salary_type = this.data.salary_type + timelist_id
      } else {
        if (this.data.salary_type.indexOf(timelist_id) == "-1") {
          salary_type = this.data.salary_type + ',' + timelist_id
        } else {
          if (salary_type.length > 1) {
            salary_type = salary_type.replace(timelist_id + ',', "")
            salary_type = salary_type.replace(',' + timelist_id, "")
          } else {
            salary_type = salary_type.replace(timelist_id, "")
          }
        }
      }
      this.setData({
        timeList: this.data.timeList,
        salary_type: salary_type,
      })
      // console.log(this.data.salary_type)
    } else {

      //点击全部
      let timeList = this.data.timeList;
      for (var i = 0; i < timeList.length; i++) {
        timeList[i]["isSelected"] = false;
      }
      this.setData({
        salary_type: '',
        timeList: timeList,
        timelistindex: "-1",
      })

    }



  },
  //选择直播类型
  click_platType: function(e) {
    // console.log(e)
    if (e.currentTarget.dataset.recuittypeindex >= 0) {
      this.setData({
        recuittypeindex: null,
      })

      //点击除了全部
      let recuitType = this.data.recuitType;
      // console.log(this.data.recuitType)    
      let index = e.currentTarget.dataset.recuittypeindex;
      let item = recuitType[index];
      item.isSelected = !item.isSelected;
      //加入选择的主播类型
      let anchortype_id = e.currentTarget.dataset.anchortype_id;
      let anchor_type = this.data.anchor_type;
      if (this.data.anchor_type == "") {
        anchor_type = this.data.anchor_type + anchortype_id
      } else {
        if (this.data.anchor_type.indexOf(anchortype_id) == "-1") {
          anchor_type = this.data.anchor_type + ',' + anchortype_id
        } else {
          if (anchor_type.length > 1) {
            anchor_type = anchor_type.replace(anchortype_id + ',', "")
            anchor_type = anchor_type.replace(',' + anchortype_id, "")
          } else {
            anchor_type = anchor_type.replace(anchortype_id, "")
          }
        }
      }
      this.setData({
        recuitType: this.data.recuitType,
        anchor_type: anchor_type,
      })
      // console.log(this.data.anchor_type)
      // console.log(this.data.recuitType)
    } else {

      //点击全部
      let recuitType = this.data.recuitType;
      for (var i = 0; i < recuitType.length; i++) {
        recuitType[i]["isSelected"] = false;
      }
      this.setData({
        anchor_type: '',
        recuitType: recuitType,
        recuittypeindex: "-1",
      })

    }


  },
  //选择平台
  click_platId: function(e) {
    // console.log(e)
    if (e.currentTarget.dataset.platfromindex >= 0) {
      this.setData({
        platfromIndex: null,
      })

      //点击除了全部
      let platfrom = this.data.platfrom;
      // console.log(this.data.platfrom)
      let index = e.currentTarget.dataset.platfromindex;
      let item = platfrom[index];
      item.isSelected = !item.isSelected;
      //加入选择的平台id
      let platfrom_id = e.currentTarget.dataset.platfrom_id;
      let plat_id = this.data.plat_id;
      if (this.data.plat_id == "") {
        plat_id = this.data.plat_id + platfrom_id;
      } else {
        if (this.data.plat_id.indexOf(platfrom_id) == "-1") {
          plat_id = this.data.plat_id + ',' + platfrom_id
        } else {
          if (plat_id.length > 1) {
            plat_id = plat_id.replace(platfrom_id + ',', "")
            plat_id = plat_id.replace(',' + platfrom_id, "")
          } else {
            plat_id = plat_id.replace(platfrom_id, "")
          }
        }
      }
      this.setData({
        platfrom: this.data.platfrom,
        plat_id: plat_id,
      })
      // console.log(this.data.plat_id)
      // console.log(this.data.platfrom)
    } else {

      //点击全部
      let platfrom = this.data.platfrom;
      for (var i = 0; i < platfrom.length; i++) {
        platfrom[i]["isSelected"] = false;
      }
      this.setData({
        plat_id: '',
        platfrom: platfrom,
        platfromIndex: "-1",
      })


    }

  },
  //load 下拉加载
  load: function(e) {
    // console.log(e)
    var page = this.data.page;
    this.setData({
      page: page + 1,
    })
    // console.log(this.data.page)
    this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.recommend_new);
  },
  //跳转详情页
  go_detail: function(e) {
    console.log(e)
    console.log(e.currentTarget.dataset.recruit_id)
    if (wx.getStorageSync('token') == '') {
      wx.showModal({
        content: '登录后才能看详情哦~',
        showCancel: true,
        cancelColor: '#333',
        confirmText: '登录',
        confirmColor: '#d0a76c',
        success: function(e) {
          if (e.confirm) {
            wx.redirectTo({
              url: '../../author/author',
            })
          }
        },
      })
    } else {
      if (!e.currentTarget.dataset.recruit_id) {
        var deatil_id = this.data.recruit_id;
      } else {
        var deatil_id = e.currentTarget.dataset.recruit_id;
      }
      wx.navigateTo({
        url: '../detail/detail?deatil_id=' + deatil_id,
      })
    }

  },
  //submit 封装发送请求
  submit: function(area_name, plat_id, anchor_type, pay_low, pay_high, salary_type, keep_pay, nolike, clickLike, job_method, page, offset, recommend_new) {
    // console.log("GOGOGO")
    wx.showLoading({
      title: '小主稍等~',
    })
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/timing/recruit/list',
      method: 'POST',
      data: {
        token: app.globalData.token,
        area_name: area_name,
        plat_id: plat_id,
        anchor_type: anchor_type,
        pay_low: pay_low,
        pay_high: pay_high,
        salary_type: salary_type,
        keep_pay: keep_pay,
        nolike: nolike,
        clickLike: clickLike,
        job_method: job_method,
        page: page,
        offset: offset,
        recommend_new: recommend_new,
      },
      success: function(e) {
        // console.log(e.data.data.list)
        // console.log(e.data.data.is_resume);
        that.setData({
          list: e.data.data.list,
          hot_recruit: e.data.data.recruit,
          is_resume: e.data.data.is_resume,
        })
        if (that.data.list_page > 1) {
          //卡片
          if (that.data.list_page > e.data.data.list.last_page) {
            //到底
            console.log('到底啦')
            wx.showToast({
              title: '到底啦~~',
              icon: 'none',
            })
          } else {
            //加载
            let recruit_info_new = e.data.data.list.data;
            let recruit_info_old = that.data.recruit_info;
            recruit_info_new.forEach(function(value, index) {
              value.publish_time = time.formatTimeTwo(value.publish_time, 'Y.M.D');
            })
            recruit_info_old.push(...recruit_info_new)

            that.setData({
              recruit_info: recruit_info_old,
            });
            // console.log(that.data.recruit_info)
          }


        } else {
          //其他
          if (that.data.page > 1) {
            //合并数组
            if (that.data.page > e.data.data.list.last_page) {
              //到底
              // console.log('到底啦')
              // wx.showToast({
              //   title: '到底啦~~',
              //   icon: 'none',
              // })
              that.setData({
                page: 1,
                is_last: true,
              })
              that.submit(that.data.area_name, that.data.plat_id, that.data.anchor_type, that.data.pay_low, that.data.pay_high, that.data.salary_type, that.data.keep_pay, that.data.nolike, that.data.clickLike, that.data.job_method, that.data.page, that.data.offset, that.data.recommend_new);
              wx.hideLoading()

            } else {
              //加载
              let recruit_info_new = e.data.data.list.data;
              let recruit_info_old = that.data.recruit_info;
              recruit_info_new.forEach(function(value, index) {
                value.publish_time = time.formatTimeTwo(value.publish_time, 'Y.M.D');
              })
              recruit_info_old.push(...recruit_info_new)
              that.setData({
                recruit_info: recruit_info_old,
              });
              // console.log(that.data.recruit_info)
            }
          } else {
            //普通情况
            let recruit_info = e.data.data.list.data;
            recruit_info.forEach(function(value, index) {
              value.publish_time = time.formatTimeTwo(value.publish_time, 'Y.M.D');
            })
            that.setData({
              recruit_info: recruit_info,
            });
          }
        }

        wx.hideLoading();
      }
    })
  },
  //确定
  open: function() {
    this.setData({
      flag_stick: false,
    })
    if (this.data.keep_pay >= "0") {
      var keep_num = 1;
    }
    if (this.data.pay_high >= "0") {
      var pay_num = 1;
    }
    var plat_num_str = this.data.plat_id;
    if (plat_num_str.split(",") == "") {
      var plat_num = 0;
    } else {
      var plat_num = plat_num_str.split(",").length;
    }

    // console.log(plat_num)

    var type_num_str = this.data.anchor_type;
    if (type_num_str.split(",") == "") {
      var type_num = 0;
    } else {
      var type_num = type_num_str.split(",").length;
    }


    var salary_num_str = this.data.salary_type;
    if (salary_num_str.split(",") == "") {
      var salary_num = 0;
    } else {
      var salary_num = salary_num_str.split(",").length;
    }


    this.setData({
      //mask
      mask_show: false,

      plat_show: true,
      type_show: true,
      salary_show: true,
      cycle_show: true,
      area_show: true,
      recommend_show: true,

      idx: '',
      flag_on: false,
      // 搜索初始化
      page: 1,
      recruit_info: [],

      //个数
      leixing_num: type_num + plat_num,
      yaoqiu_num: keep_num + pay_num + salary_num,
    })
    if (this.data.base_low != '' && this.data.base_high != '') {
      if (this.data.base_low > this.data.base_high) {
        wx.showToast({
          icon: "none",
          title: '期望底薪区间输入错误',
        })
      } else {
        var keep_pay = this.data.base_low + '-' + this.data.base_high;
        this.setData({
          keep_pay: keep_pay,
        })
      }

    } else {}
    if (this.data.pay_low > this.data.pay_high) {
      // wx.showToast({
      //   icon: "none",
      //   title: '期望薪资区间输入错误',
      // })
      //发送请求
      this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.recommend_new);
    } else {
      //发送请求
      this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.recommend_new);
    }

  },
  click_area: function(e) {
    // console.log(e.currentTarget.dataset.index);
    let area_show = this.data.area_show == true ? false : true;
    this.setData({
      flag_stick: true,
    })
    if (area_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    if (this.data.county == "全国") {
      // console.log("选择东城")
      this.setData({
        county: '东城区',
        area_name: '东城区',
      })
    } else {}
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,


      plat_show: true,
      type_show: true,
      salary_show: true,
      cycle_show: true,
      recommend_show: true,

      idx: e.currentTarget.dataset.index,

      area_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_plat: function(e) {
    let plat_show = this.data.plat_show == true ? false : true;
    this.setData({
      flag_stick: true,
    })
    if (plat_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      type_show: true,
      salary_show: true,
      cycle_show: true,
      area_show: true,
      recommend_show: true,

      idx: e.currentTarget.dataset.index,

      plat_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_type: function(e) {
    let type_show = this.data.type_show == true ? false : true;
    this.setData({
      flag_stick: true,
    })
    if (type_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      plat_show: true,
      salary_show: true,
      cycle_show: true,
      area_show: true,
      recommend_show: true,

      idx: e.currentTarget.dataset.index,

      type_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_recom(e) {
    console.log(e)
    let recommend_new = e.currentTarget.dataset.recommend_new;
    this.setData({
      recommend_new: recommend_new,
    })
    this.open();
  },
  click_recommend(e) {
    let recommend_show = this.data.recommend_show == true ? false : true;
    this.setData({
      flag_stick: true,
    })
    if (recommend_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      plat_show: true,
      salary_show: true,
      type_show: true,
      cycle_show: true,
      area_show: true,

      idx: e.currentTarget.dataset.index,

      recommend_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_salary: function(e) {
    let salary_show = this.data.salary_show == true ? false : true;
    this.setData({
      flag_stick: true,
    })
    if (salary_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      plat_show: true,
      type_show: true,
      cycle_show: true,
      area_show: true,
      recommend_show: true,

      idx: e.currentTarget.dataset.index,

      salary_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_cycle: function(e) {
    let cycle_show = this.data.cycle_show == true ? false : true;
    if (cycle_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      plat_show: true,
      type_show: true,
      salary_show: true,
      area_show: true,
      recommend_show: true,

      idx: e.currentTarget.dataset.index,

      cycle_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  //省市区 Start
  bindChange: function(e) {
    // console.log(e);
    var val = e.detail.value
    var t = this.data.values;
    var cityData = this.data.cityData;

    if (val[0] != t[0]) {
      // console.log('province no ');
      const citys = [];
      const countys = [];

      const citysCode = [];
      const countysCode = [];

      for (let i = 0; i < cityData[val[0]].sub.length; i++) {
        citys.push(cityData[val[0]].sub[i].name)
        citysCode.push(cityData[val[0]].sub[i].code)
      }
      for (let i = 0; i < cityData[val[0]].sub[0].sub.length; i++) {
        countys.push(cityData[val[0]].sub[0].sub[i].name)
        countysCode.push(cityData[val[0]].sub[0].sub[i].code)
      }
      // console.log(countysCode)

      this.setData({
        province: this.data.provinces[val[0]],
        provinceCode: this.data.provincesCode[val[0]],

        city: cityData[val[0]].sub[0].name,
        cityCode: cityData[val[0]].sub[0].code,
        citys: citys,
        citysCode: citysCode,

        county: cityData[val[0]].sub[0].sub[0].name,
        countyCode: cityData[val[0]].sub[0].sub[0].code,
        countys: countys,


        values: val,
        value: [val[0], 0, 0]
      })
      // console.log(this.data.province)
      this.setData({
        county: this.data.province,
        area_name: this.data.province,
      })
      return;
    }
    if (val[1] != t[1]) {
      // console.log('city no');
      const countys = [];
      const countysCode = [];

      for (let i = 0; i < cityData[val[0]].sub[val[1]].sub.length; i++) {
        countys.push(cityData[val[0]].sub[val[1]].sub[i].name);
        countysCode.push(cityData[val[0]].sub[val[1]].sub[i].code);
      }

      this.setData({
        city: this.data.citys[val[1]],
        cityCode: this.data.citysCode[val[1]],

        county: cityData[val[0]].sub[val[1]].sub[0].name,
        countyCode: cityData[val[0]].sub[val[1]].sub[0].code,
        countys: countys,
        countysCode: countysCode,

        values: val,
        value: [val[0], val[1], 0]
      })
      // console.log(this.data.city)
      this.setData({
        county: this.data.city,
        area_name: this.data.city,
      })
      return;
    }
    if (val[2] != t[2]) {
      // console.log('county no');
      this.setData({
        county: this.data.countys[val[2]],
        countyCode: this.data.countysCode[val[2]],
        values: val
      })
      // console.log(this.data.county)
      this.setData({
        county: this.data.county,
        area_name: this.data.county,
      })
      return;
    }
  },
  //省市区 End
  //加载Banner
  banner() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/timing/recruit/banner',
      method: 'POST',
      data: {
        token: app.globalData.token,
      },
      success: function(e) {
        // console.log(e)
        that.setData({
          banner: e.data.data.banner,
        })
      }
    })
  },
  //埋点
  secret() {
    wx.request({
      url: app.globalData.url + 'api/timing/common/oncilck/bottom',
      data: {
        token: app.globalData.token,
        from: 'WxMiNi',
        type: '1'
      },
      method: 'POST',
      success: (e) => {
        console.log(e)
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this;
    // console.log(options)
    this.getSwiper(1);
    this.getTab();
    that.setData({
      role: app.register_info.register_role
    })
    if (options.flag_first) {
      this.setData({
        flag_first: true,
      })
    }
    if (options.flag_falls) {
      this.setData({
        nolike: 2
      })
    }
    // if (this.data.role == "2" || this.data.role == "") {
    if (this.data.role != "1") {
      //推荐swiper
      // this.getSwiper(1);

      this.setData({
        flag_list: true,
      })
    } else {
      this.setData({
        flag_list: false,
      })
    }
    if (this.data.flag_falls) {
      that.setData({
        mark_falls: false,
      })
    }

    // this.get_anchorInfo();
    this.banner();


    wx.request({
      url: app.globalData.url + 'api/timing/platfrom/type',
      method: 'POST',
      data: {
        token: app.globalData.token,
      },
      success: function(e) {
        let platfrom = e.data.data.platfrom;
        let recuitType = e.data.data.recuitType;
        //增加 isSelected 属性
        for (var i = 0; i < platfrom.length; i++) {
          platfrom[i]["isSelected"] = false;
        }
        for (var i = 0; i < recuitType.length; i++) {
          recuitType[i]["isSelected"] = false;
        }
        that.setData({
          platfrom: platfrom,
          recuitType: recuitType,
        })
        // console.log(recuitType)
      }
    })

    this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.recommend_new);

    //省市区 Start
    // console.log("onLoad");
    tcity.init(that);

    var cityData = that.data.cityData;

    const provinces = [];
    const provincesCode = [];
    const citys = [];
    const citysCode = [];
    const countys = [];
    const countysCode = [];

    for (let i = 0; i < cityData.length; i++) {
      provinces.push(cityData[i].name);
      provincesCode.push(cityData[i].code);
    }
    // console.log('省份完成');
    for (let i = 0; i < cityData[0].sub.length; i++) {
      citys.push(cityData[0].sub[i].name);
      citysCode.push(cityData[0].sub[i].code);
    }
    // console.log('city完成');
    for (let i = 0; i < cityData[0].sub[0].sub.length; i++) {
      countys.push(cityData[0].sub[0].sub[i].name);
      countysCode.push(cityData[0].sub[0].sub[i].code);
    }

    that.setData({
      'provinces': provinces,
      'citys': citys,
      'countys': countys,
      'province': cityData[0].name,
      'city': cityData[0].sub[0].name,
      'county': '全国',
      // 'county': cityData[0].sub[0].sub[0].name,      
      //code
      'provincesCode': provincesCode,
      'citysCode': citysCode,
      'countysCode': countysCode,
      'provinceCode': cityData[0].code,
      'cityCode': cityData[0].sub[0].code,
      'countyCode': cityData[0].sub[0].sub[0].code
    })
    // console.log('初始化完成');
    //省市区 End


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
    this.animation = wx.createAnimation();
    if (app.globalData.token) {
      this.pull_info();
      this.earns();
      this.getcount();
      if (app.register_info.register_role == 1) {
        this.itemInfo()
      }
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    let that = this;
    this.navList();

    if (app.globalData.token) {
      // this.get_isupdate();
      this.invitation_alert();
      this.get_phone();
      this.pull_resume();
      this.get_is_issue();
      this.resumeStatus();
      this.get_residue_time(1);
      this.isAppear();
      this.secret();
      this.getcount();
      this.get_anchorInfo(1);
      // if (this.data.role == 1) {
      //   this.itemInfo()
      // }
    }
    that.setData({
      role: app.register_info.register_role
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})